package com.example.administrator.xinyutg.fragment;


import android.os.Bundle;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.administrator.xinyutg.R;
import com.example.administrator.xinyutg.adapter.DataAdapter;
import com.example.administrator.xinyutg.bean.GroupData;
import com.example.administrator.xinyutg.costants.Path;
import com.example.administrator.xinyutg.task.DataDownTask;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class SellerFragment extends Fragment {


    private ListView lvSeller;
    private List<GroupData> list;
    private DataAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v= inflater.inflate(R.layout.fragment_seller, container, false);

        initView(v);
        adapter = new DataAdapter(list,getActivity());
        initData();
        lvSeller.setAdapter(adapter);

        return v;
    }

    private void initData() {
        DataDownTask task=new DataDownTask(list,adapter);
        task.execute(Path.PATH_SELLER);
    }

    private void initView(View v) {
        lvSeller = (ListView) v.findViewById(R.id.lv_seller);
        list = new ArrayList<GroupData>();
    }


}
